/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.teste;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import server.dao.OrderDAO;
import server.dao.ProductDAO;
import server.domain.*;

/**
 *
 * @author fillipe
 */
public class OrderTest {

    public static void main(String[] args) {
        //insert();
        update();
    }
    
    public static void update(){
        OrderDAO dao = new OrderDAO();
        List<OrderItem> itens = new ArrayList<OrderItem>();
    }

    public static void insert() {
        OrderDAO dao = new OrderDAO();
        ProductDAO pDao = new ProductDAO();
        try {
            Product p1 = pDao.getById(1);
            Product p2 = pDao.getById(2);
            Product p3 = pDao.getById(3);
            Order order = new Order(new Client(1l));
            List<OrderItem> itens = new ArrayList<OrderItem>();
            itens.add(new OrderItem(
                    new PKOrderItem(null, p1),
                    25,
                    p1.getPrice(),
                    (p1.getPrice().multiply(new BigDecimal(25))),
                    (p1.getPrice().multiply(new BigDecimal(25))).multiply(new BigDecimal(0.02))));
            itens.add(new OrderItem(
                    new PKOrderItem(null, p2),
                    8,
                    p2.getPrice(),
                    (p2.getPrice().multiply(new BigDecimal(8))),
                    new BigDecimal(0)));
            itens.add(new OrderItem(
                    new PKOrderItem(null, p3),
                    15,
                    p3.getPrice(),
                    (p3.getPrice().multiply(new BigDecimal(15))),
                    (p3.getPrice().multiply(new BigDecimal(15))).multiply(new BigDecimal(0.02))));
            dao.save(order, itens);
        } catch (Exception exception) {
            System.out.println("deu pau");
        }
    }
}
